{% extends 'website/base.html' %}
{% load static %}

{% block title %}CCRadio - Album: {{ album.artist.name }} - {{ album.title }}{% endblock %}

{% block header %}
    <link rel="stylesheet" href={% static 'website/album.css' %}>
{% endblock %}

{% block page %}
    <div id="album_body">
        <h1>{{ album.artist.name }}</h1>
        <h2>{{ album.title }}</h2>
        <br>
        {% if member %}
            <a href="{% url 'song_add' artist_handle=album.artist.handle album_slug=album.slug %}">
                Add Song
            </a>
            <br>
        {% endif %}
        {% if songs %}
            <form method="POST">
                {% csrf_token %}
                {{ ratings }}
                <table>
                    <tr>
                        <th>Title</th>
                        <th>Duration</th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                    {% for song in songs %}
                        <tr>
                            <td>{{ song.title }}</td>
                            <td>{{ song.duration }}</td>
                            {% if user.is_authenticated %}
                                <td>
                                    <input type="submit" name="{{song.slug}}" value="Request">
                                </td>
                                <td>
                                    <span class="ratespan">
                                        <button type="submit" class="star-btn{% if song.ind_rating == 5 %} rating{% endif %}" id="{{song.slug}}-5" name="{{song.slug}}" value="5" />
                                        <button type="submit" class="star-btn{% if song.ind_rating == 4 %} rating{% endif %}" id="{{song.slug}}-4" name="{{song.slug}}" value="4" />
                                        <button type="submit" class="star-btn{% if song.ind_rating == 3 %} rating{% endif %}" id="{{song.slug}}-3" name="{{song.slug}}" value="3" />
                                        <button type="submit" class="star-btn{% if song.ind_rating == 2 %} rating{% endif %}" id="{{song.slug}}-2" name="{{song.slug}}" value="2" />
                                        <button type="submit" class="star-btn{% if song.ind_rating == 1 %} rating{% endif %}" id="{{song.slug}}-1" name="{{song.slug}}" value="1" />
                                    </span>
                                </td>
                            {% else %}
                                <td></td>
                                <td></td>
                            {% endif %}
                            <td>
                                {% if song.id in queued_songs %}
                                  <p>* In Queue *</p>
                                {% endif %}
                                <p>{{song.ind_rating}}</p>
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </form>
        {% else %}
            <h4>No songs uploaded for this album yet.</h4>
        {% endif %}
    </div>
{% endblock %}
